-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for parsing expressions attached to EnumConstantDecl #45
Conversation
CXAvailability_Deprecated = 1, | ||
CXAvailability_NotAvailable = 2, | ||
CXAvailability_NotAccessible = 3, | ||
CXAvailability_Available, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header file doesn't explicitly set the values for most enums and we don't need to either.
@@ -13,7 +13,7 @@ public enum CXCallingConv | |||
CXCallingConv_X86RegCall = 8, | |||
CXCallingConv_IntelOclBicc = 9, | |||
CXCallingConv_Win64 = 10, | |||
CXCallingConv_X86_64Win64 = 10, | |||
CXCallingConv_X86_64Win64 = CXCallingConv_Win64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of traversing a declaration reference expression
CXCodeComplete_IncludeBriefComments = 4, | ||
CXCodeComplete_SkipPreamble = 8, | ||
CXCodeComplete_IncludeCompletionsWithFixIts = 16, | ||
CXCodeComplete_IncludeMacros = 0x01, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of traversing an integer literal expression
CXCompletionContext_NaturalLanguage = 2097152, | ||
CXCompletionContext_IncludedFile = 4194304, | ||
CXCompletionContext_Unknown = 8388607, | ||
CXCompletionContext_AnyType = 1 << 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of traversing a binary operator expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
CXCompletionContext_MacroName = 1 << 20, | ||
CXCompletionContext_NaturalLanguage = 1 << 21, | ||
CXCompletionContext_IncludedFile = 1 << 22, | ||
CXCompletionContext_Unknown = ((1 << 23) - 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even works with parentheses
CXGlobalOpt_None = 0x0, | ||
CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, | ||
CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, | ||
CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing | CXGlobalOpt_ThreadBackgroundPriorityForEditing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and combining multiple declaration references
@@ -3,8 +3,8 @@ namespace ClangSharp | |||
public enum CXLanguageKind | |||
{ | |||
CXLanguage_Invalid = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of the native header explicitly setting the value for one entry, but not the subsequent declarations
@@ -89,12 +89,17 @@ public static int Run(InvocationContext context) | |||
arr = arr.Concat(defines.Select(x => "-D" + x)).ToArray(); | |||
arr = arr.Concat(additionalArgs).ToArray(); | |||
|
|||
var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also updated this to start passing in some flags. Namely, not processing function bodies currently and including implicit attribute information (which ensures we aren't missing anything if the user specifies additional command line options).
@@ -258,7 +268,7 @@ public CXChildVisitResult VisitTranslationUnit(CXCursor cursor, CXCursor parent, | |||
{ | |||
Debug.Assert(parent.Kind == CXCursorKind.CXCursor_TranslationUnit); | |||
|
|||
if (cursor.Location.IsInSystemHeader || !cursor.Location.IsFromMainFile) | |||
if (!cursor.Location.IsFromMainFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to just check if we aren't in the main file; which ultimately allows users to generate bindings for system headers as well.
This is an exciting change! Thank you so much. |
This just updates the binding generator to traverse expressions attached to enum constant declarations. This means that the generated code will more closely match the source files.